// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

/// Implements a client for the Cloud Resource Manager API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_resourcemanager_v3::client::Folders;
/// let client = Folders::builder().build().await?;
/// // use `client` to make requests to the Cloud Resource Manager API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Manages Cloud Platform folder resources.
/// Folders can be used to organize the resources under an
/// organization and to control the policies applied to groups of resources.
///
/// # Configuration
///
/// To configure `Folders` use the `with_*` methods in the type returned
/// by [builder()][Folders::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://cloudresourcemanager.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::folders::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::folders::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `Folders` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `Folders` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct Folders {
    inner: std::sync::Arc<dyn super::stub::dynamic::Folders>,
}

impl Folders {
    /// Returns a builder for [Folders].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_resourcemanager_v3::client::Folders;
    /// let client = Folders::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::folders::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::folders::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::Folders + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Folders>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Folders> {
        super::transport::Folders::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Folders> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::Folders::new)
    }

    /// Retrieves a folder identified by the supplied resource name.
    /// Valid folder resource names have the format `folders/{folder_id}`
    /// (for example, `folders/1234`).
    /// The caller must have `resourcemanager.folders.get` permission on the
    /// identified folder.
    pub fn get_folder(&self) -> super::builder::folders::GetFolder {
        super::builder::folders::GetFolder::new(self.inner.clone())
    }

    /// Lists the folders that are direct descendants of supplied parent resource.
    /// `list()` provides a strongly consistent view of the folders underneath
    /// the specified parent resource.
    /// `list()` returns folders sorted based upon the (ascending) lexical ordering
    /// of their display_name.
    /// The caller must have `resourcemanager.folders.list` permission on the
    /// identified parent.
    pub fn list_folders(&self) -> super::builder::folders::ListFolders {
        super::builder::folders::ListFolders::new(self.inner.clone())
    }

    /// Search for folders that match specific filter criteria.
    /// `search()` provides an eventually consistent view of the folders a user has
    /// access to which meet the specified filter criteria.
    ///
    /// This will only return folders on which the caller has the
    /// permission `resourcemanager.folders.get`.
    pub fn search_folders(&self) -> super::builder::folders::SearchFolders {
        super::builder::folders::SearchFolders::new(self.inner.clone())
    }

    /// Creates a folder in the resource hierarchy.
    /// Returns an `Operation` which can be used to track the progress of the
    /// folder creation workflow.
    /// Upon success, the `Operation.response` field will be populated with the
    /// created Folder.
    ///
    /// In order to succeed, the addition of this new folder must not violate
    /// the folder naming, height, or fanout constraints.
    ///
    /// + The folder's `display_name` must be distinct from all other folders that
    ///   share its parent.
    /// + The addition of the folder must not cause the active folder hierarchy
    ///   to exceed a height of 10. Note, the full active + deleted folder hierarchy
    ///   is allowed to reach a height of 20; this provides additional headroom when
    ///   moving folders that contain deleted folders.
    /// + The addition of the folder must not cause the total number of folders
    ///   under its parent to exceed 300.
    ///
    /// If the operation fails due to a folder constraint violation, some errors
    /// may be returned by the `CreateFolder` request, with status code
    /// `FAILED_PRECONDITION` and an error description. Other folder constraint
    /// violations will be communicated in the `Operation`, with the specific
    /// `PreconditionFailure` returned in the details list in the `Operation.error`
    /// field.
    ///
    /// The caller must have `resourcemanager.folders.create` permission on the
    /// identified parent.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_folder(&self) -> super::builder::folders::CreateFolder {
        super::builder::folders::CreateFolder::new(self.inner.clone())
    }

    /// Updates a folder, changing its `display_name`.
    /// Changes to the folder `display_name` will be rejected if they violate
    /// either the `display_name` formatting rules or the naming constraints
    /// described in the
    /// [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder]
    /// documentation.
    ///
    /// The folder's `display_name` must start and end with a letter or digit,
    /// may contain letters, digits, spaces, hyphens and underscores and can be
    /// between 3 and 30 characters. This is captured by the regular expression:
    /// `[\p{L}\p{N}][\p{L}\p{N}_- ]{1,28}[\p{L}\p{N}]`.
    /// The caller must have `resourcemanager.folders.update` permission on the
    /// identified folder.
    ///
    /// If the update fails due to the unique name constraint then a
    /// `PreconditionFailure` explaining this violation will be returned
    /// in the Status.details field.
    ///
    /// [google.cloud.resourcemanager.v3.Folders.CreateFolder]: crate::client::Folders::create_folder
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_folder(&self) -> super::builder::folders::UpdateFolder {
        super::builder::folders::UpdateFolder::new(self.inner.clone())
    }

    /// Moves a folder under a new resource parent.
    /// Returns an `Operation` which can be used to track the progress of the
    /// folder move workflow.
    /// Upon success, the `Operation.response` field will be populated with the
    /// moved folder.
    /// Upon failure, a `FolderOperationError` categorizing the failure cause will
    /// be returned - if the failure occurs synchronously then the
    /// `FolderOperationError` will be returned in the `Status.details` field.
    /// If it occurs asynchronously, then the FolderOperation will be returned
    /// in the `Operation.error` field.
    /// In addition, the `Operation.metadata` field will be populated with a
    /// `FolderOperation` message as an aid to stateless clients.
    /// Folder moves will be rejected if they violate either the naming, height,
    /// or fanout constraints described in the
    /// [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder]
    /// documentation. The caller must have `resourcemanager.folders.move`
    /// permission on the folder's current and proposed new parent.
    ///
    /// [google.cloud.resourcemanager.v3.Folders.CreateFolder]: crate::client::Folders::create_folder
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn move_folder(&self) -> super::builder::folders::MoveFolder {
        super::builder::folders::MoveFolder::new(self.inner.clone())
    }

    /// Requests deletion of a folder. The folder is moved into the
    /// [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED]
    /// state immediately, and is deleted approximately 30 days later. This method
    /// may only be called on an empty folder, where a folder is empty if it
    /// doesn't contain any folders or projects in the
    /// [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. If
    /// called on a folder in
    /// [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED]
    /// state the operation will result in a no-op success.
    /// The caller must have `resourcemanager.folders.delete` permission on the
    /// identified folder.
    ///
    /// [google.cloud.resourcemanager.v3.Folder.State.ACTIVE]: crate::model::folder::State::Active
    /// [google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED]: crate::model::folder::State::DeleteRequested
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_folder(&self) -> super::builder::folders::DeleteFolder {
        super::builder::folders::DeleteFolder::new(self.inner.clone())
    }

    /// Cancels the deletion request for a folder. This method may be called on a
    /// folder in any state. If the folder is in the
    /// [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state the
    /// result will be a no-op success. In order to succeed, the folder's parent
    /// must be in the
    /// [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. In
    /// addition, reintroducing the folder into the tree must not violate folder
    /// naming, height, and fanout constraints described in the
    /// [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder]
    /// documentation. The caller must have `resourcemanager.folders.undelete`
    /// permission on the identified folder.
    ///
    /// [google.cloud.resourcemanager.v3.Folder.State.ACTIVE]: crate::model::folder::State::Active
    /// [google.cloud.resourcemanager.v3.Folders.CreateFolder]: crate::client::Folders::create_folder
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn undelete_folder(&self) -> super::builder::folders::UndeleteFolder {
        super::builder::folders::UndeleteFolder::new(self.inner.clone())
    }

    /// Gets the access control policy for a folder. The returned policy may be
    /// empty if no such policy or resource exists. The `resource` field should
    /// be the folder's resource name, for example: "folders/1234".
    /// The caller must have `resourcemanager.folders.getIamPolicy` permission
    /// on the identified folder.
    pub fn get_iam_policy(&self) -> super::builder::folders::GetIamPolicy {
        super::builder::folders::GetIamPolicy::new(self.inner.clone())
    }

    /// Sets the access control policy on a folder, replacing any existing policy.
    /// The `resource` field should be the folder's resource name, for example:
    /// "folders/1234".
    /// The caller must have `resourcemanager.folders.setIamPolicy` permission
    /// on the identified folder.
    pub fn set_iam_policy(&self) -> super::builder::folders::SetIamPolicy {
        super::builder::folders::SetIamPolicy::new(self.inner.clone())
    }

    /// Returns permissions that a caller has on the specified folder.
    /// The `resource` field should be the folder's resource name,
    /// for example: "folders/1234".
    ///
    /// There are no permissions required for making this API call.
    pub fn test_iam_permissions(&self) -> super::builder::folders::TestIamPermissions {
        super::builder::folders::TestIamPermissions::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::folders::GetOperation {
        super::builder::folders::GetOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud Resource Manager API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_resourcemanager_v3::client::Organizations;
/// let client = Organizations::builder().build().await?;
/// // use `client` to make requests to the Cloud Resource Manager API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Allows users to manage their organization resources.
///
/// # Configuration
///
/// To configure `Organizations` use the `with_*` methods in the type returned
/// by [builder()][Organizations::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://cloudresourcemanager.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::organizations::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::organizations::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `Organizations` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `Organizations` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct Organizations {
    inner: std::sync::Arc<dyn super::stub::dynamic::Organizations>,
}

impl Organizations {
    /// Returns a builder for [Organizations].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_resourcemanager_v3::client::Organizations;
    /// let client = Organizations::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::organizations::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::organizations::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::Organizations + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Organizations>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Organizations> {
        super::transport::Organizations::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Organizations> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::Organizations::new)
    }

    /// Fetches an organization resource identified by the specified resource name.
    pub fn get_organization(&self) -> super::builder::organizations::GetOrganization {
        super::builder::organizations::GetOrganization::new(self.inner.clone())
    }

    /// Searches organization resources that are visible to the user and satisfy
    /// the specified filter. This method returns organizations in an unspecified
    /// order. New organizations do not necessarily appear at the end of the
    /// results, and may take a small amount of time to appear.
    ///
    /// Search will only return organizations on which the user has the permission
    /// `resourcemanager.organizations.get`
    pub fn search_organizations(&self) -> super::builder::organizations::SearchOrganizations {
        super::builder::organizations::SearchOrganizations::new(self.inner.clone())
    }

    /// Gets the access control policy for an organization resource. The policy may
    /// be empty if no such policy or resource exists. The `resource` field should
    /// be the organization's resource name, for example: "organizations/123".
    ///
    /// Authorization requires the IAM permission
    /// `resourcemanager.organizations.getIamPolicy` on the specified organization.
    pub fn get_iam_policy(&self) -> super::builder::organizations::GetIamPolicy {
        super::builder::organizations::GetIamPolicy::new(self.inner.clone())
    }

    /// Sets the access control policy on an organization resource. Replaces any
    /// existing policy. The `resource` field should be the organization's resource
    /// name, for example: "organizations/123".
    ///
    /// Authorization requires the IAM permission
    /// `resourcemanager.organizations.setIamPolicy` on the specified organization.
    pub fn set_iam_policy(&self) -> super::builder::organizations::SetIamPolicy {
        super::builder::organizations::SetIamPolicy::new(self.inner.clone())
    }

    /// Returns the permissions that a caller has on the specified organization.
    /// The `resource` field should be the organization's resource name,
    /// for example: "organizations/123".
    ///
    /// There are no permissions required for making this API call.
    pub fn test_iam_permissions(&self) -> super::builder::organizations::TestIamPermissions {
        super::builder::organizations::TestIamPermissions::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::organizations::GetOperation {
        super::builder::organizations::GetOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud Resource Manager API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_resourcemanager_v3::client::Projects;
/// let client = Projects::builder().build().await?;
/// // use `client` to make requests to the Cloud Resource Manager API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Manages Google Cloud Projects.
///
/// # Configuration
///
/// To configure `Projects` use the `with_*` methods in the type returned
/// by [builder()][Projects::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://cloudresourcemanager.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::projects::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::projects::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `Projects` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `Projects` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct Projects {
    inner: std::sync::Arc<dyn super::stub::dynamic::Projects>,
}

impl Projects {
    /// Returns a builder for [Projects].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_resourcemanager_v3::client::Projects;
    /// let client = Projects::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::projects::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::projects::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::Projects + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Projects>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Projects> {
        super::transport::Projects::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::Projects> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::Projects::new)
    }

    /// Retrieves the project identified by the specified `name` (for example,
    /// `projects/415104041262`).
    ///
    /// The caller must have `resourcemanager.projects.get` permission
    /// for this project.
    pub fn get_project(&self) -> super::builder::projects::GetProject {
        super::builder::projects::GetProject::new(self.inner.clone())
    }

    /// Lists projects that are direct children of the specified folder or
    /// organization resource. `list()` provides a strongly consistent view of the
    /// projects underneath the specified parent resource. `list()` returns
    /// projects sorted based upon the (ascending) lexical ordering of their
    /// `display_name`. The caller must have `resourcemanager.projects.list`
    /// permission on the identified parent.
    pub fn list_projects(&self) -> super::builder::projects::ListProjects {
        super::builder::projects::ListProjects::new(self.inner.clone())
    }

    /// Search for projects that the caller has both `resourcemanager.projects.get`
    /// permission on, and also satisfy the specified query.
    ///
    /// This method returns projects in an unspecified order.
    ///
    /// This method is eventually consistent with project mutations; this means
    /// that a newly created project may not appear in the results or recent
    /// updates to an existing project may not be reflected in the results. To
    /// retrieve the latest state of a project, use the
    /// [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] method.
    ///
    /// [google.cloud.resourcemanager.v3.Projects.GetProject]: crate::client::Projects::get_project
    pub fn search_projects(&self) -> super::builder::projects::SearchProjects {
        super::builder::projects::SearchProjects::new(self.inner.clone())
    }

    /// Request that a new project be created. The result is an `Operation` which
    /// can be used to track the creation process. This process usually takes a few
    /// seconds, but can sometimes take much longer. The tracking `Operation` is
    /// automatically deleted after a few hours, so there is no need to call
    /// `DeleteOperation`.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_project(&self) -> super::builder::projects::CreateProject {
        super::builder::projects::CreateProject::new(self.inner.clone())
    }

    /// Updates the `display_name` and labels of the project identified by the
    /// specified `name` (for example, `projects/415104041262`). Deleting all
    /// labels requires an update mask for labels field.
    ///
    /// The caller must have `resourcemanager.projects.update` permission for this
    /// project.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_project(&self) -> super::builder::projects::UpdateProject {
        super::builder::projects::UpdateProject::new(self.inner.clone())
    }

    /// Move a project to another place in your resource hierarchy, under a new
    /// resource parent.
    ///
    /// Returns an operation which can be used to track the process of the project
    /// move workflow.
    /// Upon success, the `Operation.response` field will be populated with the
    /// moved project.
    ///
    /// The caller must have `resourcemanager.projects.move` permission on the
    /// project, on the project's current and proposed new parent.
    ///
    /// If project has no current parent, or it currently does not have an
    /// associated organization resource, you will also need the
    /// `resourcemanager.projects.setIamPolicy` permission in the project.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn move_project(&self) -> super::builder::projects::MoveProject {
        super::builder::projects::MoveProject::new(self.inner.clone())
    }

    /// Marks the project identified by the specified
    /// `name` (for example, `projects/415104041262`) for deletion.
    ///
    /// This method will only affect the project if it has a lifecycle state of
    /// [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE].
    ///
    /// This method changes the Project's lifecycle state from
    /// [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE]
    /// to
    /// [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED].
    /// The deletion starts at an unspecified time,
    /// at which point the Project is no longer accessible.
    ///
    /// Until the deletion completes, you can check the lifecycle state
    /// checked by retrieving the project with [GetProject]
    /// [google.cloud.resourcemanager.v3.Projects.GetProject],
    /// and the project remains visible to [ListProjects]
    /// [google.cloud.resourcemanager.v3.Projects.ListProjects].
    /// However, you cannot update the project.
    ///
    /// After the deletion completes, the project is not retrievable by
    /// the  [GetProject]
    /// [google.cloud.resourcemanager.v3.Projects.GetProject],
    /// [ListProjects]
    /// [google.cloud.resourcemanager.v3.Projects.ListProjects], and
    /// [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects]
    /// methods.
    ///
    /// This method behaves idempotently, such that deleting a `DELETE_REQUESTED`
    /// project will not cause an error, but also won't do anything.
    ///
    /// The caller must have `resourcemanager.projects.delete` permissions for this
    /// project.
    ///
    /// [google.cloud.resourcemanager.v3.Project.State.ACTIVE]: crate::model::project::State::Active
    /// [google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED]: crate::model::project::State::DeleteRequested
    /// [google.cloud.resourcemanager.v3.Projects.SearchProjects]: crate::client::Projects::search_projects
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_project(&self) -> super::builder::projects::DeleteProject {
        super::builder::projects::DeleteProject::new(self.inner.clone())
    }

    /// Restores the project identified by the specified
    /// `name` (for example, `projects/415104041262`).
    /// You can only use this method for a project that has a lifecycle state of
    /// [DELETE_REQUESTED]
    /// [Projects.State.DELETE_REQUESTED].
    /// After deletion starts, the project cannot be restored.
    ///
    /// The caller must have `resourcemanager.projects.undelete` permission for
    /// this project.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn undelete_project(&self) -> super::builder::projects::UndeleteProject {
        super::builder::projects::UndeleteProject::new(self.inner.clone())
    }

    /// Returns the IAM access control policy for the specified project, in the
    /// format `projects/{ProjectIdOrNumber}` e.g. projects/123.
    /// Permission is denied if the policy or the resource do not exist.
    pub fn get_iam_policy(&self) -> super::builder::projects::GetIamPolicy {
        super::builder::projects::GetIamPolicy::new(self.inner.clone())
    }

    /// Sets the IAM access control policy for the specified project, in the
    /// format `projects/{ProjectIdOrNumber}` e.g. projects/123.
    ///
    /// CAUTION: This method will replace the existing policy, and cannot be used
    /// to append additional IAM settings.
    ///
    /// Note: Removing service accounts from policies or changing their roles can
    /// render services completely inoperable. It is important to understand how
    /// the service account is being used before removing or updating its roles.
    ///
    /// The following constraints apply when using `setIamPolicy()`:
    ///
    /// + Project does not support `allUsers` and `allAuthenticatedUsers` as
    ///   `members` in a `Binding` of a `Policy`.
    ///
    /// + The owner role can be granted to a `user`, `serviceAccount`, or a group
    ///   that is part of an organization. For example,
    ///   group@myownpersonaldomain.com could be added as an owner to a project in
    ///   the myownpersonaldomain.com organization, but not the examplepetstore.com
    ///   organization.
    ///
    /// + Service accounts can be made owners of a project directly
    ///   without any restrictions. However, to be added as an owner, a user must be
    ///   invited using the Cloud Platform console and must accept the invitation.
    ///
    /// + A user cannot be granted the owner role using `setIamPolicy()`. The user
    ///   must be granted the owner role using the Cloud Platform Console and must
    ///   explicitly accept the invitation.
    ///
    /// + Invitations to grant the owner role cannot be sent using
    ///   `setIamPolicy()`;
    ///   they must be sent only using the Cloud Platform Console.
    ///
    /// + If the project is not part of an organization, there must be at least
    ///   one owner who has accepted the Terms of Service (ToS) agreement in the
    ///   policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner
    ///   from the policy will fail. This restriction also applies to legacy
    ///   projects that no longer have owners who have accepted the ToS. Edits to
    ///   IAM policies will be rejected until the lack of a ToS-accepting owner is
    ///   rectified. If the project is part of an organization, you can remove all
    ///   owners, potentially making the organization inaccessible.
    ///
    pub fn set_iam_policy(&self) -> super::builder::projects::SetIamPolicy {
        super::builder::projects::SetIamPolicy::new(self.inner.clone())
    }

    /// Returns permissions that a caller has on the specified project, in the
    /// format `projects/{ProjectIdOrNumber}` e.g. projects/123..
    pub fn test_iam_permissions(&self) -> super::builder::projects::TestIamPermissions {
        super::builder::projects::TestIamPermissions::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::projects::GetOperation {
        super::builder::projects::GetOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud Resource Manager API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_resourcemanager_v3::client::TagBindings;
/// let client = TagBindings::builder().build().await?;
/// // use `client` to make requests to the Cloud Resource Manager API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Allow users to create and manage TagBindings between TagValues and
/// different Google Cloud resources throughout the GCP resource hierarchy.
///
/// # Configuration
///
/// To configure `TagBindings` use the `with_*` methods in the type returned
/// by [builder()][TagBindings::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://cloudresourcemanager.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::tag_bindings::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::tag_bindings::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `TagBindings` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `TagBindings` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct TagBindings {
    inner: std::sync::Arc<dyn super::stub::dynamic::TagBindings>,
}

impl TagBindings {
    /// Returns a builder for [TagBindings].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_resourcemanager_v3::client::TagBindings;
    /// let client = TagBindings::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::tag_bindings::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::tag_bindings::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::TagBindings + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::TagBindings>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::TagBindings> {
        super::transport::TagBindings::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::TagBindings> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::TagBindings::new)
    }

    /// Lists the TagBindings for the given Google Cloud resource, as specified
    /// with `parent`.
    ///
    /// NOTE: The `parent` field is expected to be a full resource name:
    /// <https://cloud.google.com/apis/design/resource_names#full_resource_name>
    pub fn list_tag_bindings(&self) -> super::builder::tag_bindings::ListTagBindings {
        super::builder::tag_bindings::ListTagBindings::new(self.inner.clone())
    }

    /// Creates a TagBinding between a TagValue and a Google Cloud resource.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_tag_binding(&self) -> super::builder::tag_bindings::CreateTagBinding {
        super::builder::tag_bindings::CreateTagBinding::new(self.inner.clone())
    }

    /// Deletes a TagBinding.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_tag_binding(&self) -> super::builder::tag_bindings::DeleteTagBinding {
        super::builder::tag_bindings::DeleteTagBinding::new(self.inner.clone())
    }

    /// Return a list of effective tags for the given Google Cloud resource, as
    /// specified in `parent`.
    pub fn list_effective_tags(&self) -> super::builder::tag_bindings::ListEffectiveTags {
        super::builder::tag_bindings::ListEffectiveTags::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::tag_bindings::GetOperation {
        super::builder::tag_bindings::GetOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud Resource Manager API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_resourcemanager_v3::client::TagHolds;
/// let client = TagHolds::builder().build().await?;
/// // use `client` to make requests to the Cloud Resource Manager API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Allow users to create and manage TagHolds for TagValues. TagHolds represent
/// the use of a Tag Value that is not captured by TagBindings but
/// should still block TagValue deletion (such as a reference in a policy
/// condition). This service provides isolated failure domains by cloud location
/// so that TagHolds can be managed in the same location as their usage.
///
/// # Configuration
///
/// To configure `TagHolds` use the `with_*` methods in the type returned
/// by [builder()][TagHolds::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://cloudresourcemanager.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::tag_holds::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::tag_holds::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `TagHolds` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `TagHolds` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct TagHolds {
    inner: std::sync::Arc<dyn super::stub::dynamic::TagHolds>,
}

impl TagHolds {
    /// Returns a builder for [TagHolds].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_resourcemanager_v3::client::TagHolds;
    /// let client = TagHolds::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::tag_holds::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::tag_holds::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::TagHolds + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::TagHolds>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::TagHolds> {
        super::transport::TagHolds::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::TagHolds> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::TagHolds::new)
    }

    /// Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same
    /// resource and origin exists under the same TagValue.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_tag_hold(&self) -> super::builder::tag_holds::CreateTagHold {
        super::builder::tag_holds::CreateTagHold::new(self.inner.clone())
    }

    /// Deletes a TagHold.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_tag_hold(&self) -> super::builder::tag_holds::DeleteTagHold {
        super::builder::tag_holds::DeleteTagHold::new(self.inner.clone())
    }

    /// Lists TagHolds under a TagValue.
    pub fn list_tag_holds(&self) -> super::builder::tag_holds::ListTagHolds {
        super::builder::tag_holds::ListTagHolds::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::tag_holds::GetOperation {
        super::builder::tag_holds::GetOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud Resource Manager API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_resourcemanager_v3::client::TagKeys;
/// let client = TagKeys::builder().build().await?;
/// // use `client` to make requests to the Cloud Resource Manager API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Allow users to create and manage tag keys.
///
/// # Configuration
///
/// To configure `TagKeys` use the `with_*` methods in the type returned
/// by [builder()][TagKeys::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://cloudresourcemanager.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::tag_keys::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::tag_keys::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `TagKeys` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `TagKeys` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct TagKeys {
    inner: std::sync::Arc<dyn super::stub::dynamic::TagKeys>,
}

impl TagKeys {
    /// Returns a builder for [TagKeys].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_resourcemanager_v3::client::TagKeys;
    /// let client = TagKeys::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::tag_keys::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::tag_keys::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::TagKeys + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::TagKeys>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::TagKeys> {
        super::transport::TagKeys::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::TagKeys> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::TagKeys::new)
    }

    /// Lists all TagKeys for a parent resource.
    pub fn list_tag_keys(&self) -> super::builder::tag_keys::ListTagKeys {
        super::builder::tag_keys::ListTagKeys::new(self.inner.clone())
    }

    /// Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the
    /// key does not exist or the user does not have permission to view it.
    pub fn get_tag_key(&self) -> super::builder::tag_keys::GetTagKey {
        super::builder::tag_keys::GetTagKey::new(self.inner.clone())
    }

    /// Retrieves a TagKey by its namespaced name.
    /// This method will return `PERMISSION_DENIED` if the key does not exist
    /// or the user does not have permission to view it.
    pub fn get_namespaced_tag_key(&self) -> super::builder::tag_keys::GetNamespacedTagKey {
        super::builder::tag_keys::GetNamespacedTagKey::new(self.inner.clone())
    }

    /// Creates a new TagKey. If another request with the same parameters is
    /// sent while the original request is in process, the second request
    /// will receive an error. A maximum of 1000 TagKeys can exist under a parent
    /// at any given time.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_tag_key(&self) -> super::builder::tag_keys::CreateTagKey {
        super::builder::tag_keys::CreateTagKey::new(self.inner.clone())
    }

    /// Updates the attributes of the TagKey resource.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_tag_key(&self) -> super::builder::tag_keys::UpdateTagKey {
        super::builder::tag_keys::UpdateTagKey::new(self.inner.clone())
    }

    /// Deletes a TagKey. The TagKey cannot be deleted if it has any child
    /// TagValues.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_tag_key(&self) -> super::builder::tag_keys::DeleteTagKey {
        super::builder::tag_keys::DeleteTagKey::new(self.inner.clone())
    }

    /// Gets the access control policy for a TagKey. The returned policy may be
    /// empty if no such policy or resource exists. The `resource` field should
    /// be the TagKey's resource name. For example, "tagKeys/1234".
    /// The caller must have
    /// `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on
    /// the specified TagKey.
    pub fn get_iam_policy(&self) -> super::builder::tag_keys::GetIamPolicy {
        super::builder::tag_keys::GetIamPolicy::new(self.inner.clone())
    }

    /// Sets the access control policy on a TagKey, replacing any existing
    /// policy. The `resource` field should be the TagKey's resource name.
    /// For example, "tagKeys/1234".
    /// The caller must have `resourcemanager.tagKeys.setIamPolicy` permission
    /// on the identified tagValue.
    pub fn set_iam_policy(&self) -> super::builder::tag_keys::SetIamPolicy {
        super::builder::tag_keys::SetIamPolicy::new(self.inner.clone())
    }

    /// Returns permissions that a caller has on the specified TagKey.
    /// The `resource` field should be the TagKey's resource name.
    /// For example, "tagKeys/1234".
    ///
    /// There are no permissions required for making this API call.
    pub fn test_iam_permissions(&self) -> super::builder::tag_keys::TestIamPermissions {
        super::builder::tag_keys::TestIamPermissions::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::tag_keys::GetOperation {
        super::builder::tag_keys::GetOperation::new(self.inner.clone())
    }
}

/// Implements a client for the Cloud Resource Manager API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_resourcemanager_v3::client::TagValues;
/// let client = TagValues::builder().build().await?;
/// // use `client` to make requests to the Cloud Resource Manager API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// Allow users to create and manage tag values.
///
/// # Configuration
///
/// To configure `TagValues` use the `with_*` methods in the type returned
/// by [builder()][TagValues::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://cloudresourcemanager.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::tag_values::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::tag_values::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `TagValues` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `TagValues` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct TagValues {
    inner: std::sync::Arc<dyn super::stub::dynamic::TagValues>,
}

impl TagValues {
    /// Returns a builder for [TagValues].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_resourcemanager_v3::client::TagValues;
    /// let client = TagValues::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::tag_values::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::tag_values::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::TagValues + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::TagValues>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::TagValues> {
        super::transport::TagValues::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::TagValues> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::TagValues::new)
    }

    /// Lists all TagValues for a specific TagKey.
    pub fn list_tag_values(&self) -> super::builder::tag_values::ListTagValues {
        super::builder::tag_values::ListTagValues::new(self.inner.clone())
    }

    /// Retrieves a TagValue. This method will return `PERMISSION_DENIED` if the
    /// value does not exist or the user does not have permission to view it.
    pub fn get_tag_value(&self) -> super::builder::tag_values::GetTagValue {
        super::builder::tag_values::GetTagValue::new(self.inner.clone())
    }

    /// Retrieves a TagValue by its namespaced name.
    /// This method will return `PERMISSION_DENIED` if the value does not exist
    /// or the user does not have permission to view it.
    pub fn get_namespaced_tag_value(&self) -> super::builder::tag_values::GetNamespacedTagValue {
        super::builder::tag_values::GetNamespacedTagValue::new(self.inner.clone())
    }

    /// Creates a TagValue as a child of the specified TagKey. If a another
    /// request with the same parameters is sent while the original request is in
    /// process the second request will receive an error. A maximum of 1000
    /// TagValues can exist under a TagKey at any given time.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_tag_value(&self) -> super::builder::tag_values::CreateTagValue {
        super::builder::tag_values::CreateTagValue::new(self.inner.clone())
    }

    /// Updates the attributes of the TagValue resource.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_tag_value(&self) -> super::builder::tag_values::UpdateTagValue {
        super::builder::tag_values::UpdateTagValue::new(self.inner.clone())
    }

    /// Deletes a TagValue. The TagValue cannot have any bindings when it is
    /// deleted.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_tag_value(&self) -> super::builder::tag_values::DeleteTagValue {
        super::builder::tag_values::DeleteTagValue::new(self.inner.clone())
    }

    /// Gets the access control policy for a TagValue. The returned policy may be
    /// empty if no such policy or resource exists. The `resource` field should
    /// be the TagValue's resource name. For example: `tagValues/1234`.
    /// The caller must have the
    /// `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on
    /// the identified TagValue to get the access control policy.
    pub fn get_iam_policy(&self) -> super::builder::tag_values::GetIamPolicy {
        super::builder::tag_values::GetIamPolicy::new(self.inner.clone())
    }

    /// Sets the access control policy on a TagValue, replacing any existing
    /// policy. The `resource` field should be the TagValue's resource name.
    /// For example: `tagValues/1234`.
    /// The caller must have `resourcemanager.tagValues.setIamPolicy` permission
    /// on the identified tagValue.
    pub fn set_iam_policy(&self) -> super::builder::tag_values::SetIamPolicy {
        super::builder::tag_values::SetIamPolicy::new(self.inner.clone())
    }

    /// Returns permissions that a caller has on the specified TagValue.
    /// The `resource` field should be the TagValue's resource name. For example:
    /// `tagValues/1234`.
    ///
    /// There are no permissions required for making this API call.
    pub fn test_iam_permissions(&self) -> super::builder::tag_values::TestIamPermissions {
        super::builder::tag_values::TestIamPermissions::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::tag_values::GetOperation {
        super::builder::tag_values::GetOperation::new(self.inner.clone())
    }
}
